import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import AutoImport from 'unplugin-auto-import/vite' //自动引入vue3的hooks
import PiniaAutoRefs from 'pinia-auto-refs' //store响应式插件

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vueJsx(),
    AutoImport({
      imports: [
        'pinia',
        {
          '@/helper/pinia-auto-refs': ['useStore'], //使用useStore调用store.js
        },
      ],
    }),
    PiniaAutoRefs({
      storeDir: 'src/stores', //文件位置
      excludes: ['index'],
      outputFile: 'src/helper/pinia-auto-refs.ts', //自动生成文件位置
    }),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  }
})
